#ifndef WINDOWWIDGET_H
#define WINDOWWIDGET_H
/*
 Window Widget runs everything in the simulator and is basically Main
 */


#include <QWidget>         //Runs window creation
#include <QGLWidget>       //Runs openGL feature creation
#include <QtGui>           //Also window: buttons, toolbars etc
#include <QTimer>          //timers: for animation loops
#include <QFont>           //For printing text
#include <list>            //data structure
#include <QString>         //because QStrings are more special then strings

#include <vector>          //For use in meshes, models

#include "lights.h"        //All our Light code is in here: sun and other lights
#include "camera.h"        //All our camera code is here: move viewpoint
#include "boat.h"          //All our boat data: mesh, type, name, speed, heading, position
#include "splitter.h"      //String parser: good when loading from files

/*
 //Goals:
     terrain
     model loader
     models
     AI
     saving
 */

namespace Ui {//creating the class within the UI namespace (everything in the class is assumed to have Ui:: before it)
    class windowWidget;
}

class windowWidget : public QGLWidget  //Creating window using GL and non-GL widget features
{
    Q_OBJECT

public:
    explicit windowWidget(QWidget *parent = 0); //constructor with parent defaulting to window type
    ~windowWidget();                            //destructor

protected:
    //User input device handlers
    void mousePressEvent(QMouseEvent *event);   //callback for Mouse Press button Event
    void mouseMoveEvent(QMouseEvent *event);    //callback for Mouse dragging events
    void mouseReleaseEvent(QMouseEvent *event); //callback for mouse Realease button events
    void keyPressEvent(QKeyEvent *event);       //callback for keyboard button press events

    //GL display functions
    void initializeGL();                        //sets background and draw colors, loads initial world, sets lighting
    void paintGL();                             //draws the world with most recent updates
    void resizeGL(int width, int height);       //changes window size (and size of everything in window)
    void setupViewport(int width, int height);  //sets the view to some type of 3-D to 2-D form

    //simulator mechanics functions
    void checkCollisions();                     //checks collisions between ships and land
    void resetGame();                           //resets everything to starting positions
    void autoPlay();                            //begins time and runs everything on current instructions: (run, not autoplay)
    void loadScenario();                        //-load from file: .scn type //function: file dialog
    void saveScenario();                        //-save to file: .scn type   //function: file dialog

private slots:
    void animate();                             //timer based function for animating objects
    

private:
    Ui::windowWidget *ui;                       //ui object (the window and contents)
    //Model* worldModel;                        //object that stores everything to be drawn (ships, land, sky, sea)
    blackjack::Terrain *terrain;                //creates a terrain object to hold land
    int worldLoaded;                            //does world exist or not: loaded or not
    QTimer timer;                               //timer for animate/paint functions
    std::vector<boat> fleet;                    //storage for ships

    //menu variables (mostly index)
    int playMode;                               //menu, map, or play mode
    int subMenu;                                //which menu are we in
    int menuSel;                                //what option are we on
    int initMenuX, initMenuY, menuX, menuY;     //position values for text
    int yInc;                                   //horizontal spacing
    int speedChoice;                            //current speed of simulation

    lights sceneLights;                         //default lights (so we can always see)
    camera myCamera;                            //default camera (so we can move view)
};

#endif // WINDOWWIDGET_H
